<template>
  <sc-contextmenu
    ref="contextmenu"
    @command="handleCommand"
    @visible-change="visibleChange"
  >
    <sc-contextmenu-item
      command="closeConn"
      title="关闭连接"
      suffix="Alt+←"
      v-if="tree.node && tree.node.childrenLoaded"
    ></sc-contextmenu-item>
    <sc-contextmenu-item
      command="openConn"
      title="打开连接"
      suffix="Alt+←"
      v-else
    ></sc-contextmenu-item>
    <sc-contextmenu-item
      command="b"
      title="重新加载(R)"
      suffix="Ctrl+R"
      icon="el-icon-refresh"
    ></sc-contextmenu-item>
    <sc-contextmenu-item title="切换兼容性模式" divided>
      <sc-contextmenu-item command="c1" title="二级菜单1"></sc-contextmenu-item>
      <sc-contextmenu-item title="二级菜单2">
        <sc-contextmenu-item
          command="c2-1"
          title="三级菜单1"
        ></sc-contextmenu-item>
        <sc-contextmenu-item
          command="c2-2"
          title="三级菜单2"
        ></sc-contextmenu-item>
        <sc-contextmenu-item
          command="c2-3"
          title="三级菜单3"
        ></sc-contextmenu-item>
      </sc-contextmenu-item>
      <sc-contextmenu-item command="c3" title="二级菜单3"></sc-contextmenu-item>
    </sc-contextmenu-item>
    <sc-contextmenu-item
      command="d"
      title="属性(P)"
      divided
      :disabled="row && row.state == 0"
    ></sc-contextmenu-item>
    <sc-contextmenu-item
      command="e"
      title="设置state=1"
      v-if="row && row.state == 0"
    ></sc-contextmenu-item>
  </sc-contextmenu>
</template>
<script>
export default {
  name: "connRightMenu",
  components: {},
  expose: ["openMenu"],
  data() {
    return {
      node: {},
    };
  },
  methods: {
    handleCommand(command) {
      if (command == "closeConn") {
        this.$emit("closeConn");
      }
      if (command == "openConn") {
        this.$emit("openConn");
      }
    },
    openMenu(node, e) {
      this.node = node;
      this.$refs.contextmenu.openMenu(e);
    },

    visibleChange(visible) {
      if (!visible) {
      }
    },
  },
};
</script>